package com.chen.gcode.compoments;

import javax.swing.*;

public class TextFileCell extends JComponent {
    JLabel titleLabel;
    JTextField contentTextField;
    JButton button;


    private String title = "";
    private String content = "";
    private String buttonTitle = "";

    public TextFileCell() {
        initView();
    }

    public TextFileCell(String title, String content, String buttonTitle) {
        initView();
        this.title = title;
        this.content = content;
        this.buttonTitle = buttonTitle;
        titleLabel.setText(title);
        contentTextField.setText(content);
        button.setText(buttonTitle);
    }

    private void initView(){
        Integer x = 5;
        Integer y = 5;
        Integer w = 80;
        Integer h = 40;

        titleLabel = new JLabel();
        titleLabel.setBounds(x,y,w,h);
        add(titleLabel);

        x += 5+ w;
        w = 300;

        contentTextField = new JTextField();
        contentTextField.setBounds(x,y,w,h);
        add(contentTextField);


        x += 5+ w;
        w = 80;
        button = new JButton("选择微雕文件");
        button.setBounds(x,y,w,h);
        add(button);


    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        titleLabel.setText(title);
        this.title = title;
    }

    public String getContent() {
        return contentTextField.getText();
    }

    public void setContent(String content) {
        contentTextField.setText(content);
        this.content = content;
    }

    public String getButtonTitle() {
        return buttonTitle;
    }

    public void setButtonTitle(String buttonTitle) {
        button.setText(buttonTitle);
        this.buttonTitle = buttonTitle;
    }

    public JLabel getTitleLabel() {
        return titleLabel;
    }

    public void setTitleLabel(JLabel titleLabel) {
        this.titleLabel = titleLabel;
    }

    public JTextField getContentTextField() {
        return contentTextField;
    }

    public void setContentTextField(JTextField contentTextField) {
        this.contentTextField = contentTextField;
    }

    public JButton getButton() {
        return button;
    }

    public void setButton(JButton button) {
        this.button = button;
    }
}
